// package: learn-go
// filename: sort
// author: diogoxiang@gmail.com
// time: 2023/12/11 16:06

package sort

import "sort"

type urlCount struct {
	URL   string
	Count int
}

func SortURLs(urlCounts map[string]int) []urlCount {
	var urls []urlCount
	for url, count := range urlCounts {
		urls = append(urls, urlCount{url, count})
	}
	sort.Slice(urls, func(i, j int) bool {
		return urls[i].Count > urls[j].Count // 降序排序
	})
	return urls
}
